//
//  MainTabBarItem.m
//  FirstProject
//
//  Created by 戴庆云 on 15/9/14.
//  Copyright (c) 2015年 dqy. All rights reserved.
//

#import "MainTabBarItem.h"

@implementation MainTabBarItem

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        //图片视图
        _tabBarImageView = [[UIImageView alloc] initWithFrame:CGRectMake((frame.size.width - 22) / 2.0, 7, 22, 20)];
        _tabBarImageView.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:_tabBarImageView];
        
        //创建文本
        _tabBarTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 28, frame.size.width, 20)];
        _tabBarTitleLabel.textAlignment = NSTextAlignmentCenter;
        _tabBarTitleLabel.font = [UIFont systemFontOfSize:10];
        _tabBarTitleLabel.textColor = [UIColor blackColor];
        [self addSubview:_tabBarTitleLabel];
    }
    return self;
}

- (void)setTabBarTitleName:(NSString *) titleString {
    if (_tabBarTitleName != titleString) {
        _tabBarTitleName = [titleString copy];
        _tabBarTitleLabel.text = _tabBarTitleName;
    }
}

- (void)setTabBarImageName:(NSString *) imageString {
    if (_tabBarImageName != imageString) {
        _tabBarImageName = [imageString copy];
        _tabBarImageView.image = [UIImage imageNamed:_tabBarImageName];
    }
}

@end
